import { createSlice } from "@reduxjs/toolkit";

const initialState = {
  value: 1,
}

export const counterSlice = createSlice({
  name: 'list',
  initialState,
  reducers: {
    increment: (state) => {
      state.value += 1
    },
    decrement: (state) => {
      state.value -= 1
    }
  },
})

// 这里的actions对应的是上面的reducers function
export const { increment, decrement } = counterSlice.actions

export default counterSlice.reducer